<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录</title>
</head>
<body>
<?php
/**
 * Created by PhpStorm.
 * User: iceberg
 * Date: 2018-10-10
 * Time: 10:36
 */
session_start();
$name = isset($_SESSION['name']) ? $_SESSION['name']:'';
$info = '请您登录';
if(isset($_POST['submit']))
{
    $name = isset($_POST['name']) ? $_POST['name']:'';
    $password = isset($_POST['password']) ? $_POST['password']:'';
    //var_dump($password);die;
    if($name === "phedu" && $password === "8888")
    {
        //echo 'ok';die;

        $_SESSION['name'] = 'phedu';
        $_SESSION['password'] = '8888';
        $_SESSION['is_login'] = 'ok';
        header("location:/logout.php");
    }else{
        $info = '用户名和密码错误！';
    }
}

?>
<h1><?php echo $info; ?></h1>
<form method="post">
    <input name="name" type="text" value="<?php echo $name; ?>"/><br/>
    <input name="password" type="password" type="text" /><br/>
    <input type="submit" name="submit" value="提交" /> <input type="reset" value="重置" />
</form>
</body>
</html>

